package practice;

public class practice005 {
	// 一个六位数乘以2,3,4,5,6还是由原来的六个数组成(142857)
	public static void main(String[] args) {
		int i, j, k, t, x, n, m, c = 0, q = 0, d = 0;
		int[] a = new int[6];
		int[] b = new int[6];
		for (i = 10000; i < 200000; i++) {
			x = i;
			k = 0;
			while (x > 0) {
				a[k++] = x % 10;
				x = x / 10;
			}
			for (n = 0; n < 6; n++) {
				q = 0;
				for (m = 1 + n; m < 6; m++) {
					if (a[n] == a[m]) {
						q++;
						break;
					}
				}
				if (q == 1)
					break;
			}
			if (q == 1)
				continue;
			d = 0;
			for (j = 2; j < 7; j++) {
				t = i * j;
				k = 0;
				while (t > 0) {
					b[k++] = t % 10;
					t = t / 10;
				}
				for (n = 0; n < 6; n++) {
					c = 0;
					for (m = 0; m < 6; m++) {
						if (a[n] == b[m])
							c++;
					}
					if (c == 0)
						break;
				}
				if (n != 6)
					break;
				else
					d++;
			}
			if (d == 5) {
				System.out.println(i);
				break;
			}
		}

	}
}
